372. 超级次方
为保证权益,题目请参考 372. 超级次方(From LeetCode).
解决方案1
Python
python
# 372. 超级次方
# https://leetcode-cn.com/problems/super-pow/
from typing import List
from functools import reduce
class Solution:
def superPow(self, a: int, b: List[int]) -> int:
a = a % 1337
return reduce(lambda n, bi: (((n ** 10) % 1337) * ((a ** bi) % 1337)) % 1337, b, 1)
if __name__ == '__main__':
solution = Solution()
print(solution.superPow(2, [2, 1]))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16